////////////////////////////////////////////////////////////////////////////////////////
// Stauffer Public Perceptions of Women's Inclusion and Feelings of Political Efficacy
// Replication Code - Main Text
///////////////////////////////////////////////////////////////////////////////////////

***********
// TABLE 1 
***********

*setworking directory 

use 1618_CCES.dta, clear 

*Additive
xtmixed efficacy_1 c.r_estimate gender_r c.ideo7 i.party strong_partisan know_fed religiosity ///
coll white c.age##c.age employed woman_sen woman_rep c.stateleg i.year || state:
estimates store add

*Interactive
xtmixed efficacy_1 c.r_estimate##i.gender_r c.ideo7 i.party strong_partisan know_fed religiosity ///
coll white c.age##c.age employed i.woman_sen##i.gender_r i.woman_rep##i.gender_r c.stateleg##i.gender_r i.year || state:, cov(uns)

estimates store interactive

*Generate Latex Code For Table
estout add interactive, cells(b(star fmt(%9.3f)) se(par)) ///
style(tex) stats(N) nobaselevels interaction ("X") starlevels (* .1 ** .05 *** .01)

*Generate Predictions for Plots
xtmixed efficacy_1 c.r_estimate gender_r c.ideo7 i.party strong_partisan know_fed religiosity ///
coll white c.age##c.age employed woman_sen woman_rep c.stateleg i.year || state:

mgen, at(r_estimate=(0(10)60) gender_r==1 white==1 employed==0 party==1 ///
strong_partisan==0 year==2018 woman_sen==0 woman_rep==0) ///
atmeans stub(pooled) replace 


***********
// TABLE 2
***********

use 17_CCES.dta, clear 

*Additive No Perceptions
meoprobit state_responsive c.state gender_r c.ideo7##c.state_ideo01 congruence i.party strong_partisan know_state ///
c.age##c.age white coll employed religiosity if state_guess!=. ||StateAbbr: , cov(uns) 

estimates store add_nop

*Interactive No Perceptions
meoprobit state_responsive c.state##gender_r c.ideo7##c.state_ideo01 congruence i.party strong_partisan know_state ///
c.age##c.age white coll employed religiosity if state_guess!=. ||StateAbbr: , cov(uns)

estimates store int_nop

*Additive Perceptions
meoprobit state_responsive c.state gender_r c.state_guess gender_r c.ideo7##c.state_ideo01 congruence i.party strong_partisan know_state ///
c.age##c.age white coll employed religiosity ||StateAbbr: , cov(uns)

estimates store add_p

*Interactive Perceptions 
meoprobit state_responsive c.state##i.gender_r c.state_guess##i.gender_r c.ideo7##c.state_ideo01 congruence i.party strong_partisan know_state ///
c.age##c.age white coll employed religiosity ||StateAbbr: , cov(uns)

estimates store int_p

*Generate Latex Code For Table
estout add_nop int_nop add_p int_p, cells(b(star fmt(%9.3f)) se(par)) ///
style(tex) stats(N) nobaselevels interaction ("X") starlevels (* .1 ** .05 *** .01)

*Generate Predictions for Plots
meoprobit state_responsive c.state gender_r c.state_guess gender_r c.ideo7##c.state_ideo01 congruence i.party strong_partisan know_state ///
c.age white coll employed religiosity ||StateAbbr: , cov(uns)

mgen, predict(outcome(1) fixedonly) at(state_guess=(0(5)60) gender_r==1 congruence==0 white==1 employed==0 ///
party==1  strong_partisan==0) atmeans stub(women1) replace
mgen, predict(outcome(2) fixedonly) at(state_guess=(0(5)60) gender_r==1 congruence==0 white==1 employed==0 ///
party==1  strong_partisan==0) atmeans stub(women2) replace
mgen, predict(outcome(3) fixedonly) at(state_guess=(0(5)60) gender_r==1 congruence==0 white==1 employed==0 ///
party==1 strong_partisan==0) atmeans stub(women3) replace
mgen, predict(outcome(4) fixedonly) at(state_guess=(0(5)60) gender_r==1 congruence==0 white==1 employed==0 ///
party==1  strong_partisan==0) atmeans stub(women4) replace


***********
// TABLE 3 
***********

use 18_panel.dta, clear 

reg eff_diff r_diff, robust 
estimates store mod1 

reg eff_diff c.r_diff##i.gender_r, robust 
estimates store mod2 

reg eff_diff c.r_diff rep_diff sen_diff state_diff, robust
estimates store mod3

reg eff_diff c.r_diff##i.gender_r rep_diff rep_int sen_diff sen_int c.state_diff##i.gender_r, robust
estimates store mod4

*Generate Latex Code For Table
estout mod1 mod2 mod3 mod4, cells(b(star fmt(%9.3f)) se(par)) ///
style(tex) stats(N) nobaselevels interaction ("X") starlevels (* .1 ** .05 *** .01)

*Generate Predictions for Plots
reg eff_diff r_diff, robust 

mchange r_diff, delta(-25) statistics(all)
mchange r_diff, delta(-20) statistics(all)
mchange r_diff, delta(-15) statistics(all)
mchange r_diff, delta(-10) statistics(all)
mchange r_diff, delta(-5) statistics(all)
mchange r_diff, delta(5) statistics(all)
mchange r_diff, delta(10) statistics(all)
mchange r_diff, delta(15) statistics(all)
mchange r_diff, delta(20) statistics(all)

